<template>
  <el-card>
    <template #header>
      <div class="top">地勤人员</div>
    </template>
    <el-form class="seach" inline>
      <el-form-item>
        <el-select v-model="value1" placeholder="骑行区域">
          <el-option
            v-for="item in options1"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-select v-model="value1" placeholder="状态">
          <el-option
            v-for="item in options1"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-input placeholder="姓名" />
      </el-form-item>
      <el-form-item>
        <el-input placeholder="账号" />
      </el-form-item>
      <el-form-item>
        <el-input placeholder="手机号" />
      </el-form-item>
      <el-form-item>
        <el-input placeholder="工号" />
      </el-form-item>
      <el-form-item>
        <el-button
          icon="el-icon-search"
          native-type="submit"
          type="primary"
          @click="handleQuery"
        >
          查询
        </el-button>
        <el-button @click="handleReset()">重置</el-button>
      </el-form-item>
      <el-form-item class="right">
        <el-button type="success" @click="handleAdd()">添加地勤人员</el-button>
      </el-form-item>
      <!-- <div class="right"></div> -->
    </el-form>
    <div ref="custom-table" class="custom-table-container">
      <el-table border>
        <el-table-column label="账号" />
        <el-table-column label="姓名" />
        <el-table-column label="工号" />
        <el-table-column label="手机号" />
        <el-table-column label="负责区域" width="200" />
        <el-table-column label="状态" />
        <el-table-column label="添加时间" />
        <el-table-column
          align="center"
          fixed="right"
          label="操作"
          show-overflow-tooltip
          width="150"
        />
      </el-table>
      <el-pagination
        background
        :current-page="queryForm.pageNo"
        :layout="layout"
        :page-size="queryForm.pageSize"
        :total="total"
        @current-change="handleCurrentChange"
        @size-change="handleSizeChange"
      />
      <!-- <table-edit ref="edit" @fetch-data="fetchData" /> -->
    </div>
  </el-card>
</template>

<script>
  import { getList } from '@/api/table'
  export default {
    data() {
      return {
        options1: [
          { value: '选项1', label: '全部' },
          { value: '选项2', label: '已实名' },
          { value: '选项3', label: '未实名' },
        ],
        value1: '',
        options2: [
          { value: '选项1', label: '全部' },
          { value: '选项2', label: '暂停使用' },
          { value: '选项3', label: '正常' },
        ],
        value2: '',
        layout: 'total, sizes, prev, pager, next, jumper',
        total: 0,
        selectRows: '',
        // 初始状态下跳转页面的数据
        queryForm: {
          pageNo: 1,
          pageSize: 20,
          title: '',
        },
      }
    },
    created() {
      this.fetchData()
    },
    methods: {
      handleAdd() {},
      handleReset() {},
      handleSizeChange(val) {
        this.queryForm.pageSize = val
        this.fetchData()
      },
      handleCurrentChange(val) {
        this.queryForm.pageNo = val
        this.fetchData()
      },
      handleQuery() {
        this.queryForm.pageNo = 1
        this.fetchData()
      },
      async fetchData() {
        this.listLoading = true
        const { data } = await getList(this.queryForm)
        const { list, total } = data
        this.list = list
        const imageList = []
        list.forEach((item) => {
          imageList.push(item.img)
        })
        this.imageList = imageList
        this.total = total
        this.listLoading = false
      },
    },
  }
</script>

<style scoped>
  .top {
    font-size: 20px;
    padding-bottom: 10px;
  }
  .card {
    padding: 10px;
  }
  .seach {
    position: relative;
  }
  .right {
    position: absolute;
    right: 10px;
  }
</style>
